package com.myspring.lab.control;

import com.myspring.lab.dao.DbConnnect;
import com.myspring.lab.dao.DbUser;
import com.myspring.lab.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.Model;
import javax.servlet.http.HttpSession;

@Controller
public class doLogin {
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String login(String username, String password, HttpSession session){
        DbConnnect dbConnnect = new DbConnnect();
        DbUser dbUser = new DbUser();
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        if(dbUser.verifyUser(user)){
            session.setAttribute("user",username);
            return "redirect:main";
        }else{
            return "redirect:login.html";
        }
    }
}
